home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 43.zip
/
Sources C - WorkDisk II.adf
/
line9.c
< prev
next >
Wrap
C/C++ Source or Header
|
1987-02-18
|
4KB
|
239 lines
#include "exec/types.h"
#include "intuition/intuition.h"
#include "graphics/gfxmacros.h"
#include "math.h"
struct IntuitionBase *IntuitionBase;
struct Window *NoBorder;
struct GfxBase *GfxBase;
struct Screen *Scrn;
struct IntuiMessage *mesg;
struct RastPort *r;
#define INTUITION_REV 29
#define GRAPHICS_REV 29
main()
{
ULONG flags,mclass;
SHORT x,y,w,h,d,c0,c1,einde,txt0ycrd,txt1ycrd,txt2ycrd,ix;
USHORT mode;
int len;
char *txt0,*txt1,*txt2;
double il,ih;
/* static UWORD patroon[]=
{
0x0AA0,
0xA00A,
0x0BB0,
0xB00B,
0xB00B,
0x0BB0,
0xA00A,
0x0AA0
}; */
VOID OpenALL();
OpenALL();
/* ======Open een lores custom screen====== */
y=0;
w=320;
h=200;
d=5; /* max 32 colors ! */
c0=0x00;
c1=0x01;
mode=NULL;
Scrn=(struct Screen *)
make_screen(y,w,h,d,c0,c1,mode,NULL);
/* ======open een borderless window ====== */
x=y=0;
w=320;
h=200;
flags=ACTIVATE|NOCAREREFRESH|BORDERLESS|BACKDROP;
NoBorder=(struct Window *)
make_window(x,y,w,h,NULL,flags,Scrn);
/* ======geen screentitel====== */
ShowTitle(Scrn,0);
/* ======definitie van RPort !====== */
r=NoBorder->RPort;
for(x=1;x<16;x++)
{
SetRGB4(ViewPortAddress(NoBorder), x, x,(7-x)%16,15);
SetRGB4(ViewPortAddress(NoBorder),16+x,15,x,0);
};
for(x=0;x<360;x++)
{
SetAPen(r,((SHORT)x)%32);
line(r,79,49 ,ih+=1,40.0);
line(r,239,149,ih+=1,40.0);
line(r,239,49 ,ih+=1,40.0);
line(r,79,149 ,ih+=1,40.0);
};
for(y=1;y<256;y++)
{
for(x=1;x<16;x++)
{
SetRGB4(ViewPortAddress(NoBorder), x, x,(7-x)%16,15);
SetRGB4(ViewPortAddress(NoBorder),16+x,15,x,0);
}
};
/* ======einde in stijl !====== */
einde=0; /* init einde op 0 ! */
while (einde != 1)
{
Wait(1<<NoBorder->UserPort->mp_SigBit);
while((mesg=(struct IntuiMessage *)
GetMsg(NoBorder->UserPort))!=NULL)
{
ReplyMsg(mesg);
mclass=mesg->Class;
}
if(mclass==MOUSEBUTTONS)
{
einde=1;
cleanwindow(r);
CloseWindow(NoBorder);
CloseScreen(Scrn);
}
}
} /********************************** einde van main **********************/
VOID OpenALL()
{
/*==Intuition==*/
IntuitionBase=(struct IntuitionBase *)
OpenLibrary("intuition.library",INTUITION_REV);
if(IntuitionBase==NULL)
exit(FALSE);
/*==Graphics Library==*/
GfxBase=(struct GfxBase *)
OpenLibrary("graphics.library",GRAPHICS_REV);
if(GfxBase==NULL)
exit(FALSE);
}
make_window(x,y,w,h,name,flags,screen)
SHORT x,y,w,h;
UBYTE *name;
ULONG flags;
struct Screen *screen;
{
struct NewWindow NewWindow;
NewWindow.LeftEdge = x;
NewWindow.TopEdge = y;
NewWindow.Width = w;
NewWindow.Height = h;
NewWindow.DetailPen = -1;
NewWindow.BlockPen = -1;
NewWindow.Title = name;
NewWindow.Flags = flags;
NewWindow.IDCMPFlags = MOUSEBUTTONS;
NewWindow.Type = CUSTOMSCREEN;
NewWindow.FirstGadget = NULL;
NewWindow.CheckMark = NULL;
NewWindow.Screen = screen;
NewWindow.BitMap = NULL;
NewWindow.MinWidth = 0;
NewWindow.MinHeight = 0;
NewWindow.MaxWidth = 0;
NewWindow.MaxHeight = 0;
return(OpenWindow(&NewWindow));
}
make_screen(y,w,h,d,color0,color1,mode,name)
SHORT y,w,h,d;
UBYTE color0,color1,*name;
USHORT mode;
{
struct NewScreen NewScreen;
NewScreen.LeftEdge = 0;
NewScreen.TopEdge = y;
NewScreen.Width = w;
NewScreen.Height = h;
NewScreen.Depth = d;
NewScreen.DetailPen = color0;
NewScreen.BlockPen = color1;
NewScreen.ViewModes = mode;
NewScreen.Type = CUSTOMSCREEN;
NewScreen.Font = NULL;
NewScreen.DefaultTitle = name;
NewScreen.Gadgets = NULL;
NewScreen.CustomBitMap = NULL;
return(OpenScreen(&NewScreen));
}
line(rast,x0,y0,hoek,l)
struct RastPort *rast;
SHORT x0,y0;
double hoek,l;
{
double gnr,dx,dy;
gnr=3.141592/180.0;
dx=l*cos(hoek*gnr);
dy=l*sin(hoek*gnr);
Move(rast,(SHORT)(x0-dx),(SHORT)(y0+dy));
Draw(rast,(SHORT)(x0+dx),(SHORT)(y0-dy));
}
cleanwindow(rast)
struct RastPort *rast;
{
SHORT i,x2,y2;
SetAPen(rast,0); /* zwart */
SetBPen(rast,1); /* wit */
for(i=0;i<200;i++)
{
Move(rast,0,0);Draw(rast,319,i);
Move(rast,319,0);Draw(rast,0,i);
Move(rast,0,199);Draw(rast,319,199-i);
Move(rast,319,199);Draw(rast,0,199-i);
}
}